<template>
  <view class="pages">
    <statusList :list="list" @orderTaking="$utils.goBack()"></statusList>
  </view>
</template>

<script>
import statusList from "./components/status.vue";
export default {
  components: {
    statusList
  },
  data() {
    return {
      list: [],
      default_time: ""
    };
  },
  async onLoad(opi) {
    try {
      this.default_time =
        uni.getStorageSync("authData").local_setting.default_time.value;

      let locationData = await this.$store.dispatch("getLocation");

      let res = await this.$allrequest.distribution.scanGetOrder({
        order_no: opi.order_no ? opi.order_no : '',
				order_id: opi.order_id,
        lat: locationData.latitude,
        lng: locationData.longitude
      });
      if (!res.code) {
        res.data.data.forEach((item) => {
          if (item.delivery_time > 0) {
            item.mintune = parseInt((item.delivery_time - item.pay_time) / 60);
          } else {
            item.mintune = parseInt(
              (item.pay_time * 1000 +
                this.default_time * 60 * 1000 -
                new Date().getTime()) /
                1000 /
                60
            );
          }
        });

        this.list = res.data.data || [];
      }
    } catch (error) {
      this.$utils.toast(error);
    }
  }
};
</script>

<style scoped lang="scss">
.pages {
  background: #f2f2f2;
  min-height: 100vh;
  padding: 10rpx 0 0;
  box-sizing: border-box;
}
</style>
